package com.hotelManagerSystem.mapper;

import com.hotelManagerSystem.model.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author treasy
 * @since 2021-12-22
 */
public interface RoleMapper extends BaseMapper<Role> {

    @Select("SELECT\n" +
            "role.role_id,\n" +
            "role.role_name,\n" +
            "role.role_code\n" +
            "FROM\n" +
            "staff\n" +
            "INNER JOIN staff_role ON staff.staff_id = staff_role.staff_id\n" +
            "INNER JOIN role ON staff_role.role_id = role.role_id\n" +
            "WHERE staff.username=#{username}")
    List<Role> queryRoleListByUsername(String username);
}
